#pragma once
#include <sys/types.h>
#include <sys/socket.h>
#include <arpa/inet.h>
#include <netinet/in.h>
#include <fcntl.h>
#define Die(code)   \
    do              \
    {               \
        exit(code); \
    }               \
    while (0)       \
        ;

#define CONV(ptr) ((struct sockaddr *)(ptr))
enum
{
    SOCKETERR = 1,
    BINDERR,
    USAGEERR,
    SEV_RECV_ERR,
    EPOLL_CREATE_ERR,
    EPOLL_CTL_ERR
};
const int gdefaultsockfd = -1;
const int gbacklog = 8;

void SetNonBlock(int fd)
{
    int fl = fcntl(fd,F_GETFL);
    if(fl<0)
        return;
    fcntl(fd,F_SETFL,fl|O_NONBLOCK);
}